var app = getApp();
var api = require('../../utils/interface.js');

// pages/myUser/myUser.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    myUser:[
        {
            date:"7月",
            item:[
                {
                  avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },
                {
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },
                {
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },
                {
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },
            ]
        },
        {
            date:"6月",
            item:[
                {
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },
                {
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },{
                    avatar:'https://pic4.zhimg.com/80/a031436ec639f8a6810fab9dcf41bd63_hd.jpg',
                    name:'苦涩',
                    addDate:'2018年7月31号'
                },
            ]
        }
    ],
    current:1,
      pahe:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getKezi()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
    userAnimation:function(e){
        console.log(e)
        let monthIndex = e.currentTarget.dataset.month,
            userIndex  = e.currentTarget.dataset.user,
            myUser = this.data.myUser;
      var animate = wx.createAnimation({
          duration:1000
      })
        var gloAnimate = wx.createAnimation({
            duration: 200
        })
        console.log(monthIndex +"----"+userIndex)
    gloAnimate.opacity(0).width("110px").step()

      animate.opacity(1).width("40vw").step()
        myUser.forEach(function (value,index){
            value.item.forEach(function (item,user) {
                if (item.flag){
                    item.action = gloAnimate.export()
                    item.flag = false
                }else if
                     (index == monthIndex && user == userIndex ) {
                        item.action = animate.export()
                            item.flag = true
                    }
            })
        })
        this.setData({
            myUser:myUser
        })
  },
    currentQ:function (e) {
        let bind = e.currentTarget.dataset.bind,
            current = this.data.current
        if (bind == current){

        } else {
            current = current == 1 ? 2:1;
        }
        this.setData({
            current:current
        })
    },
    // 获取客资列表
    getKezi:function (type,page) {
        app.WxRequest(api.wxapp.GETKezi+`?type=${type}&page=${page}`,"GET",{type:1,page:1},function (data) {
            console.log(data)
        })
    }
})